package at.codejedi.sto.config;

import java.io.File;
import java.net.URL;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;

public final class Configuration {

	public static final DateFormat getDateTimeFormat() {
		return new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
	}

	public static final DecimalFormat getDecimalFormat() {
		DecimalFormat df = new DecimalFormat(",##0.00");
		DecimalFormatSymbols symbols = df.getDecimalFormatSymbols();
		symbols.setGroupingSeparator(' ');
		return df;
	}

	public static final long getDistanceBetweenBattlesInMillis() {
		return 60000;
	}

	public static final ImageIcon getFullIcon() {
		URL resource = Configuration.class.getResource("/images/Logo.png");
		if (resource != null)
			return new ImageIcon(resource);
		return null;
	}

	public static final String getLabel(String key) {
		ResourceBundle bundle = ResourceBundle.getBundle("LabelsBundle");
		return bundle.getString(key);
	}

	public static final File getPropertyFile(String fileName) {
		String userHomePath = System.getProperty("user.home");
		File userHomeFile = new File(userHomePath, "sto-combat-analyser");
		userHomeFile.mkdirs();
		File file = new File(userHomeFile, fileName);
		return file;
	}

	public static final ImageIcon getSmallIcon() {

		URL resource = Configuration.class.getResource("/images/icon.ico");
		if (resource != null)
			return new ImageIcon(resource);
		return null;
	}
}
